{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Date MCP Server + Client Tutorial\n",
        "\n",
        "This notebook demonstrates a minimal MCP server exposing `current_date` and a matching client that calls it.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import os, shutil\n",
        "os.chdir('/home/sergei/projects/ai-agents-course/6_mcp/community_contributions/date_mcp_server_client')\n",
        "print('CWD:', os.getcwd())\n",
        "print('uv path:', shutil.which('uv'))\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Show server and client code\n",
        "from pathlib import Path\n",
        "print('--- date_server.py ---')\n",
        "print(Path('date_server.py').read_text())\n",
        "print('\\n--- date_client.py ---')\n",
        "print(Path('date_client.py').read_text())\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# List tools\n",
        "from date_client import list_date_tools\n",
        "\n",
        "[t.name for t in (await list_date_tools())]\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Call current_date\n",
        "from date_client import call_date_tool\n",
        "\n",
        "res = await call_date_tool('current_date')\n",
        "contents = getattr(res, 'content', None) or getattr(res, 'contents', None)\n",
        "if contents:\n",
        "    vals = []\n",
        "    for c in contents:\n",
        "        vals.append(getattr(c, 'text', None) or getattr(c, 'value', None) or str(c))\n",
        "    ' '.join(vals)\n",
        "else:\n",
        "    res\n"
      ]
    }
  ],
  "metadata": {
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 2
}
